package com.angel.web.app;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.angel.core.base.JsonEntity;
import com.angel.core.util.JsonUtil;
import com.angel.health.BuzCmsColumn;
import com.angel.health.BuzCmsContentWithBLOBs;
import com.angel.provider.health.BuzCmsColumnProvider;
import com.angel.provider.health.BuzCmsContentProvider;

/** 
* @author 作者姓名  cheng
* @version 
* 创建时间：2016年12月1日 下午5:56:36 
* 类说明 
*/
@Controller
@RequestMapping("app/cms")
public class AppCmsController {
	@Autowired
	private BuzCmsContentProvider bcContentProvider;
	@Autowired
	private BuzCmsColumnProvider bccProvider;

	@ResponseBody
	@RequestMapping(value = "content", produces = "application/json; charset=utf-8")
	public String content(BuzCmsContentWithBLOBs bcc){
		List<Map<String, Object>> list = bcContentProvider.findAll(bcc);
		return JsonUtil.toJson(new JsonEntity("200", list));
	}
	
	@ResponseBody
	@RequestMapping(value = "column", produces = "application/json; charset=utf-8")
	public String column(BuzCmsColumn bcc){
		List<Map<String, Object>> list = bccProvider.findAll(bcc);
		return JsonUtil.toJson(new JsonEntity("200", list));
	}
	
	@RequestMapping("contentById")
	public String contentById(BuzCmsContentWithBLOBs bcc,HttpServletRequest req){
		if(bcc.getId() == null){
			return null;
		}
		bcc = bcContentProvider.findById(bcc);
		req.setAttribute("bcc", bcc);
		return "cms/app";
	}
}
